﻿@model SoftHotel.Models.Consumo

@{
    ViewBag.Title = "Agregar";
}

<h2>Agregar</h2>


<script src="@Url.Content("~/Scripts/jquery.validate.min.js")" type="text/javascript"></script>
<script src="@Url.Content("~/Scripts/jquery.validate.unobtrusive.min.js")" type="text/javascript"></script>
    <link href="@Url.Content("~/Content/themes/base/jquery.ui.all.css")" rel="stylesheet" type="text/css" />
 <script src="@Url.Content("~/Scripts/jquery.unobtrusive-ajax.js")" type="text/javascript"></script>
   <script src="@Url.Content("~/Scripts/jquery-1.5.1.min.js")" type="text/javascript"></script>    
    <script src="@Url.Content("~/Scripts/jquery-ui-1.8.11.min.js")" type="text/javascript"></script>

   


<script type="text/javascript">
    var linkObj;
    $(function () {
        $(".busqueda").button();

        $('#searchDialog').dialog({
            autoOpen: false,
            width: 900,
            resizable: false,
            modal: true
        });

        $(".busqueda").click(function () {
            //change the title of the dialgo
            linkObj = $(this);
            var dialogDiv = $('#searchDialog');
            var viewUrl = linkObj.attr('href');
            $.get(viewUrl, function (data) {
                dialogDiv.html(data);

                //open dialog
                dialogDiv.dialog('open');
            });
            return false;
        });

    });
    
    function searchSuccess() {
        var id = $("#update-message").html();
        //we update the table's info
        var parent = linkObj.closest("tr");
        document.getElementById('idCliente').value = $("#idCliente" + id.toString()).val();
        document.getElementById('nombreCliente').value = $("#nombres" + id.toString()).val();
        $('#searchDialog').dialog('close');
    }
    
</script>

<div id="searchDialog" title="Seleccionar Cliente"></div>

@using (Html.BeginForm()) {
    @Html.ValidationSummary(true)
    <fieldset>
        <legend>Consumo</legend>
  <table rules="none" style="border-color: Black; width: 900px; margin-bottom: 0px;">
	<tbody><tr>
		<td style="width: 20px;"></td>
		<td style="font-weight: bold;"> Cliente:</td>
		<td>@Html.HiddenFor(Model=> Model.idCliente) @Html.EditorFor(model => model.nombreCliente)<a class="busqueda" href="/Consumo/BuscarCliente"> <img src="/Content/Images/buscar.png" alt="0" title="Buscar" id="" border="0" height="16" width="16"/></a></td>	
		<td style="font-weight: bold;"> Reserva:</td>
		<td>@Html.DropDownList("idReserva", null, new { @onchange="location = this.value;" })
            @Html.ValidationMessageFor(model => model.idReserva)</td>	
	</tr><tr>	
		<td style="width: 20px;"></td>
        <td style="font-weight: bold;">Ambiente</td>
        <td>@Html.DropDownList("idAmbiente")
            @Html.ValidationMessageFor(model => model.idAmbiente)</td>
        <td style="font-weight: bold;">Servicio</td>
        <td>@Html.DropDownList("idServicio")
            @Html.ValidationMessageFor(model => model.idServicio)</td>
		<td>@Html.HiddenFor(model => model.tipo)</td>	
	</tr>
	
</tbody></table>

   </fieldset>
        <form action = "Agregar" method = "post">
        <center>
	        <input value="Guardar" type="submit" name = "button"/> @{/* que estos sean tipo button*/}
	        <input value="Cancelar" type="submit" name = "button"/>
        </center>
    </form>
}
